﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VechicleRepairLab
{
	public partial class Form1 : Form
	{
		private DataSet dataSet;

		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			CreateSchema();
		}

		private void CreateSchema()
		{
			dataSet = new DataSet("VechiclesRepairs");

			DataTable vechicles = dataSet.Tables.Add("Vechicles");
			vechicles.Columns.Add("VechicleUniqueId", typeof(string));
			vechicles.Columns.Add("Make", typeof (string));
			vechicles.Columns.Add("Model", typeof(string));
			vechicles.Columns.Add("Year", typeof(int));
			vechicles.PrimaryKey = new DataColumn[] { vechicles.Columns["Id"] } ;

			DataTable repairs = dataSet.Tables.Add("Repairs");
			var repairsPrimaryKey = repairs.Columns.Add("Id", typeof (int));
			repairsPrimaryKey.AutoIncrement = true;
			repairsPrimaryKey.AutoIncrementSeed = -1;
			repairsPrimaryKey.AutoIncrementStep = -1; 
			repairs.Columns.Add("VechicleUniqueId", typeof(string));
			repairs.Columns.Add("Description", typeof(string));
			repairs.Columns.Add("RepairCost", typeof(decimal));
			repairs.PrimaryKey = new DataColumn[] { repairsPrimaryKey } ;

			dataSet.Relations.Add("vechicles_repairs_relation", vechicles.Columns["VechicleUniqueId"], repairs.Columns["VechicleUniqueId"]);

			MessageBox.Show("DataSet schema was created!");
		}

		private void label1_Click(object sender, EventArgs e)
		{

		}
	}
}
